#pragma once

#include "RHITexture.h"

class ViewTexture : public RHITexture
{
	struct BuilderDetails {

		RefCountPtr<RHITexture> texture;

		VkImageViewType viewType;
		VkComponentMapping components;
		VkImageSubresourceRange subresourceRange;

		BuilderDetails();
	};

public:

	class Builder : public BuilderBase<BuilderDetails> {
		friend struct BuilderDetails;
	public:
		Builder() noexcept;
		Builder(Builder const& rhs) noexcept;
		Builder(Builder&& rhs) noexcept;
		~Builder() noexcept;
		Builder& operator=(Builder const& rhs) noexcept;
		Builder& operator=(Builder&& rhs) noexcept;

		Builder& SetTexture(RefCountPtr<RHITexture> texture) noexcept;
		Builder& SetViewType(VkImageViewType viewType) noexcept;
		Builder& SetComponents(VkComponentMapping components) noexcept;
		Builder& SetAspectMask(VkImageAspectFlags aspectMask) noexcept;
		Builder& SetBaseMipLevel(uint32 baseMipLevel) noexcept;
		Builder& SetLevelCount(uint32 levelCount) noexcept;
		Builder& SetBaseArrayLayer(uint32 baseArrayLayer) noexcept;
		Builder& SetLayerCount(uint32 layerCount) noexcept;

		RefCountPtr<ViewTexture> Build();
		RefCountPtr<ViewTexture> Build(RenderProcess* process, const std::string& name);

	private:
		friend class ColorTexture;
	};

	ViewTexture(BuilderDetails& builderDetails);

	virtual void ReleaseResource() override;

};